package com.example.lsy.zyfypt_227lsy.model;

import android.view.View;

import com.example.lsy.zyfypt_227lsy.iface.RegisterListener;
import com.example.lsy.zyfypt_227lsy.iface.Registeriface;
import com.example.lsy.zyfypt_227lsy.service.RegisterService;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.scalars.ScalarsConverterFactory;



public class RegisterModel implements Registeriface{
    private Retrofit retrofit;
    private String BASEURL = "http://amicool.neusoft.edu.cn/";
    private View view;

    public RegisterModel(){
        retrofit = new Retrofit.Builder()
                .baseUrl(BASEURL)
                .addConverterFactory(ScalarsConverterFactory.create())
                .build();
    }

    @Override
    public void getResultList(String username, String password, String tel, final RegisterListener listener) {
        RegisterService registerService=retrofit.create(RegisterService.class);
        Call<String> call =registerService.getResult(username,password,tel);
        call.enqueue(new Callback<String>() {
            @Override
            public void onResponse(Call<String> call, Response<String> response) {
                listener.onResponse(response.body());
            }

            @Override
            public void onFailure(Call<String> call, Throwable t) {
                listener.onFail(t.toString());
            }
        });

    }
}
